package com.woniuxy02;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class Test06 {
    public static void main(String[] args) {
        List<String> s1=new ArrayList<String>();
        s1.add("aaa");
        s1.add("bbb");
        s1.add("ccc");
        //遍历：增强for,迭代器，转成数组 ,List get(int index)
//        Object[] array = s1.toArray();
//        for (int i = 0; i < array.length; i++) {
//            System.out.print(array[i]+"\t");
//        }

        for(int i=0;i<s1.size();i++){
            System.out.print(s1.get(i)+"\t");
        }
        System.out.println();

        System.out.println(s1.indexOf("bbb"));
        System.out.println(s1.indexOf("xxx"));

//        Iterator<String> iterator = s1.iterator();
//        while(iterator.hasNext()){
//            System.out.println(iterator.next());
//        }

        ListIterator<String> listIterator = s1.listIterator();
        while(listIterator.hasNext()){
            System.out.println(listIterator.next());
        }

        while (listIterator.hasPrevious()){
            System.out.println(listIterator.previous());
        }


    }
}
